***
* ROLL CALL SECTION REPLICATION
***
* This is the final replication file for the data regarding actual roll call votes (final passage, amendments, procedurals, etc.)
* I copied and pasted from the do file "CategoriesSetUp"


clear
set memory 50m

 
* Prof. Rohde's data is available at https://www.msu.edu/~pipc/pipcdata.htm
use Rohde_RollCallVotes_83_108.dta, clear

* This command drops some erroneously duplicated observations from the Rohde dataset
drop if v1<=498 & v1>=489 & cong==98 
* These commands generate VoteID which assigns the bills a unique identification number
*gen v1temp=v1-10 if cong==98 & v1>=499
*replace VoteID=cong*10000+v1temp if cong==98 & v1>=499

gen VoteID=cong*10000+v1
rename v2 Aye_Rohde
rename v3 Nay_Rohde
rename v4 DemAye_Rohde
rename v5 DemNay_Rohde
rename v6 RepAye_Rohde
rename v7 RepNay_Rohde
drop v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 revote



***
* Vote Types (Final Passage, Amendment, Procedural)
***
* This makes a dummy that equals 1 for votes of the types that we call "Final Passage Votes" (See Appendix for which vote types this includes)
gen test=0
gen VoteType_Final=0
replace VoteType_Final=1 if vote<=19
replace VoteType_Final=1 if (vote>=30 & vote<=34)

* This makes a dummy that equals 1 only for votes of the type "Final Passage of Bill"
gen VoteType_FinalBill=0
replace VoteType_FinalBill=1 if vote==11
replace VoteType_FinalBill=1 if vote==15

* Amendments
gen VoteType_Amend=0
replace VoteType_Amend=1 if (vote>=21 & vote<=23)
replace VoteType_Amend=1 if (vote>=25 & vote<=29)

* Final Passage or Amendments
gen VoteType_Final_Amend=0
replace VoteType_Final_Amend=1 if (VoteType_Amend==1|VoteType_Final==1)

* Procedurals
gen VoteType_Procedural=0
* There is an incorrectly coded observation in the Rohde dataset, so this command corrects its vote type coding
****XXX***Recheck
replace vote=93 if cong==107 & session==2 & v1==872 & v1ex==366
replace VoteType_Procedural=1 if vote==24
replace VoteType_Procedural=1 if (vote>=52 & vote<=64)
replace VoteType_Procedural=1 if (vote>=66 & vote<=99)


***
* Issue Areas (Foreign vs Domestic)
***
* This section uses Rohde's coding of issue areas to classify votes by whether or not they deal with foreign policy
* The variable "issue" contains the Rohde/PIPC vote type coding, which describes the substantive issues covered by the vote.
* We originally broke votes down by what particular "component" of LI that the vote dealt with
* The variable "issue2" is the broadest category, 1="cooperation" 2="strength" 3="immigration"
* A foreign policy vote is thus a vote for which issue2>=1 

gen issue2=0
local cooperation "140 141 142 143 149 402 410 411 412 413 414 416 417 419 430 431 432 433 439 450 451 452 460 462 463 464 465 466 467 468 469 532 441 443 540 542 543 544 545 546 547 548 549 420 421 422 423 428 429"
foreach iss of local cooperation {
replace issue2 = 1 if issue==`iss'
}
local strength "145 415 418 110 111 112 113 114 115 116 117 118 119 156 190 199 240 241 242 243 244 245 246 250 259 397 530"
foreach iss of local strength {
replace issue2 = 2 if issue==`iss'
}
replace issue2=2 if issue>=300 & issue<=389
replace issue2=2 if issue>=470 & issue<=499

replace issue2=3 if issue==400 | issue==442



***
* Kupchan Mellow "Bipartisan Vote" Measure
***
* This generates the bipartisanship dummy that Kupchan and Mellow use, where a vote is bipartisan if a simple majority of both parties vote for a bill or the opposition percentages are within 20%
gen PercentDemAye = DemAye_Rohde/( DemAye_Rohde+ DemNay_Rohde)
gen PercentRepAye = RepAye_Rohde/( RepAye_Rohde+ RepNay_Rohde)
gen PercentDemNay = DemNay_Rohde/( DemAye_Rohde+ DemNay_Rohde)
gen PercentRepNay = RepNay_Rohde/( RepAye_Rohde+ RepNay_Rohde)
gen KMBipart = 0
replace KMBipart = 1 if PercentDemAye >= .50 & PercentRepAye >=.50
replace KMBipart = 1 if abs(PercentDemNay - PercentRepNay) <= .20
replace KMBipart = . if PercentDemAye == .





***
* Percent of Votes that are Bipartisan by Congress, with various breakdowns (vote type, foreign vs domestic)
***
* This section constructs the variables needed to create the plots of the percentage of bipartisan votes by year

* This generates variables that will be used in later loops, the variables will become the number of bills of a certain breakdown
foreach i of newlist OverallBipart FPBipart FPBipart_Procedural FPBipart_Final_Amend FPBipart_Final FPBipart_Amend {
	gen `i'_n=.
	}
gen year_ct=_n
gen OverallBipart=.


* These commands generate the number of bills for a certain breakdown and then the percentage of bipartisan bills by year for that breakdown
* All foreign policy ("FP") votes
gen FPBipart=.
levelsof year, local(yr)
foreach yr of numlist 1953(1)2004 {
summ KMBipart if year==`yr' & issue2>=1 
replace FPBipart=r(mean) if year_ct==`yr'
replace FPBipart_n=r(N) if year_ct==`yr'
}

* Procedural FP votes
gen FPBipart_Procedural=.
levelsof year, local(yr)
foreach yr of numlist 1953(1)2004 {
summ KMBipart if  year==`yr' & issue2>=1 & VoteType_Procedural==1
replace FPBipart_Procedural=r(mean) if year_ct==`yr'
replace FPBipart_Procedural_n=r(N) if year_ct==`yr'
}

* Final + Amendment FP Votes
gen FPBipart_Final_Amend=.
levelsof year, local(yr)
foreach yr of numlist 1953(1)2004 {
summ KMBipart if  year==`yr' & issue2>=1 & VoteType_Final_Amend==1
replace FPBipart_Final_Amend=r(mean) if year_ct==`yr'
replace FPBipart_Final_Amend_n=r(N) if year_ct==`yr'
}

* Final passage only FP votes
gen FPBipart_Final=.
levelsof year, local(yr)
foreach yr of numlist 1953(1)2004 {
summ KMBipart if  year==`yr' & issue2>=1 & VoteType_Final==1
replace FPBipart_Final=r(mean) if year_ct==`yr'
replace FPBipart_Final_n=r(N) if year_ct==`yr'
}

*Amendment only FP votes
gen FPBipart_Amend=.
levelsof year, local(yr)
foreach yr of numlist 1953(1)2004 {
summ KMBipart if  year==`yr' & issue2>=1 & VoteType_Amend==1
replace FPBipart_Amend=r(mean) if year_ct==`yr'
replace FPBipart_Amend_n=r(N) if year_ct==`yr'
}

***
* Submission Draft Figure 3
***
local low 1953
local high 2003
local gp "ytitle("",axis(1))"
twoway connect FPBipart FPBipart_Final year_ct if year_ct>`low' & year_ct<`high', title("Figure 3. Percentage of Bipartisan Foreign Policy Votes, 1953-2003", size(medium)) yaxis(1) `gp' lp(dash solid) lw(medium medium) ylab(0(.2)1, format(%02.1f)) xlab(1950(10)2004) legend(order(1 "all votes" 2 "final passage votes")) ytitle(percent bipartisan votes) xtitle(Year) msize(vsmall vsmall)
*graph save "FP-All-Final.gph", replace


***
* Submission Draft Figure 4
***
local low 1953
local high 2003
local gp "ytitle("",axis(1))"
twoway connect FPBipart_Procedural FPBipart_Amend year_ct if year_ct>`low' & year_ct<`high', title("(b) Percentage of Votes that are Bipartisan, 1953-2003", size(medium)) yaxis(1) `gp' lp(dash solid) lw(medium medium) ylab(0(.2)1, format(%02.1f)) xlab(1950(10)2004) legend(order(1 "procedural votes" 2 "amendment votes")) ytitle(percentage bipartisan votes) xtitle(Year) msize(vsmall vsmall)
graph save "FP-Proc-Amend.gph", replace
twoway connect FPBipart_Procedural_n FPBipart_Amend_n year_ct if year_ct>`low' & year_ct<`high', yaxis(1) `gp' title("(a) Number of Procedural and Amendment Votes, 1953-2003", size(medium)) lp(dash solid) lw(medium medium) xlab(1950(10)2004) ytitle(number of votes) xtitle(Year) msize(vsmall vsmall) legend(off)
graph save "FP-Proc-Amend-N.gph", replace

graph combine FP-Proc-Amend-N.gph FP-Proc-Amend.gph, imargin(tiny) col(1) iscale(.65) title("Figure 4. Trends in Procedural and Amendment Votes", size(medium))
*graph save "FP-Proc-Amend.gph", replace


***
* Submission Draft Figure 5
***
* This creates the 1970 Predicted Probability Plot
* drop  AllVotes FinalVotes ProceduralVotes AmendVotes
local cons1 "& year>=1970"
estimates clear
probit KMBipart year if issue2>=1 `cons1', robust cluster(cong)
est store All_For
predict AllVotes , pr
probit KMBipart year if VoteType_Final==1 & issue2>=1 `cons1', robust cluster(cong)
est store FP_For
predict FinalVotes  , pr
probit KMBipart year if VoteType_Procedural==1 & issue2>=1 `cons1', robust cluster(cong)
est store ProcFor
predict ProceduralVotes , pr
probit KMBipart year if VoteType_Amend==1 & issue2>=1 `cons1', robust cluster(cong)
est store FP_Amend
predict AmendVotes , pr
*esta _all  using "KT-VoteType.doc" , `order' title("Title") starlevels(+ 0.10 * 0.05 ** 0.01)  se  nom nonum nodep nogaps  b(a3)  label brackets  compress replace

preserve
duplicates drop year, force
local low 1970
local high 2003
twoway connect AllVotes Final Amend Procedural year if year>`low' & year<`high', yaxis(1) title("Figure 5. Predicted Probability of a Bipartisan Vote Over Time, 1970-2003", size(medium)) lp(dash dash_dot dot solid) lw(medium medium medium medium) msymbol(i i i i) xlab(1970(5)2005) ylab(0(.2)1, format(%02.1f)) legend(order(1 "all votes" 2 "final passage" 3 "amendments" 4 "procedural")) ytitle(predicted probability) xtitle(Year) msize(medlarge large medium medlarge)
*graph save PredictProb1970, replace
restore


***
* Statistical Analysis of Cold War Break (Produces the results mentioned in draft footnote 25)
***
gen CWBreak=0 if year<1992
replace CWBreak=1 if year>=1992
gen All=1
local cons "& year>=1980"
foreach var of varlist All VoteType_Procedural VoteType_Amend VoteType_Final {
di "`var'"
reg KMBipart CWBreak if issue2>=1 & `var'==1 `cons', cl(cong)
}
* For draft footnote 23, we looped these same commands over various permutations of starting and ending cutoffs


saveold "IS_Replication_RollCall.dta", replace


